package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/12/17 11:28
 * @description：https://leetcode-cn.com/problems/water-bottles/
 */
public class 换酒问题 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.numWaterBottles(15, 8));
    }


    class Solution {
        public int numWaterBottles(int numBottles, int numExchange) {
            int sum = 0;
            int emptyNumBottles = 0;
            while (numBottles > 0) {
                sum += numBottles;
                int curEmptyBottles = numBottles + emptyNumBottles;
                numBottles = curEmptyBottles / numExchange;
                emptyNumBottles = curEmptyBottles % numExchange;
            }
            return sum;
        }
    }
}
